package com.demo.controller.api2;

import com.alibaba.fastjson.JSON;
import com.demo.dto.CommonDto;
import com.demo.entity.Entity;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;


/**
 * @author yexi
 */
@RestController("test2")
@Api(tags = {"这是测试二"})
@Controller
public class DemoController2 {

    @RequestMapping("/demo")
    public HashMap<String, Object> demo() {
        HashMap<String, Object> result = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            result.put(String.valueOf(i), "结果" + i);
        }
        List<CommonDto> dtoList = new ArrayList<>();
        CommonDto commonDto = new CommonDto();
        commonDto.setDate(new Date());
        commonDto.setId("34");
        dtoList.add(commonDto);
        result.put("list", dtoList);
        result.put("json", JSON.toJSONString(dtoList));
        return result;
    }

    @PostMapping("/demo2")
    public Entity demo2(@RequestBody Entity e) {

        Entity entity = new Entity();
        entity.setLockGoodsStartTime(new Date());
        entity.setType(49);
        entity.setId(6L);
        entity.setDescription("哈哈哈");
        return entity;
    }

    @PostMapping("/demo3")
    public Entity demo3(Entity e) {

        Entity entity = new Entity();
        entity.setLockGoodsStartTime(new Date());
        entity.setType(49);
        entity.setId(6L);
        entity.setDescription("哈哈哈");
        return entity;
    }
}
